package com.example.orderflow.controller;

import java.util.List;

import com.example.orderflow.controller.base.ABaseController;
import com.example.orderflow.entity.query.OrderIdGenerationQuery;
import com.example.orderflow.entity.po.OrderIdGeneration;
import com.example.orderflow.entity.vo.ResponseVO;
import com.example.orderflow.service.OrderIdGenerationService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 *  Controller
 */
@RestController("orderIdGenerationController")
@RequestMapping("/orderIdGeneration")
public class OrderIdGenerationController extends ABaseController {

	@Resource
	private OrderIdGenerationService orderIdGenerationService;
	/**
	 * 根据条件分页查询
	 */
	@RequestMapping("/loadDataList")
	public ResponseVO loadDataList(OrderIdGenerationQuery query){
		return getSuccessResponseVO(orderIdGenerationService.findListByPage(query));
	}

	/**
	 * 新增
	 */
	@RequestMapping("/add")
	public ResponseVO add(OrderIdGeneration bean) {
		orderIdGenerationService.add(bean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增
	 */
	@RequestMapping("/addBatch")
	public ResponseVO addBatch(@RequestBody List<OrderIdGeneration> listBean) {
		orderIdGenerationService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增/修改
	 */
	@RequestMapping("/addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<OrderIdGeneration> listBean) {
		orderIdGenerationService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id查询对象
	 */
	@RequestMapping("/getOrderIdGenerationById")
	public ResponseVO getOrderIdGenerationById(Integer id) {
		return getSuccessResponseVO(orderIdGenerationService.getOrderIdGenerationById(id));
	}

	/**
	 * 根据Id修改对象
	 */
	@RequestMapping("/updateOrderIdGenerationById")
	public ResponseVO updateOrderIdGenerationById(OrderIdGeneration bean,Integer id) {
		orderIdGenerationService.updateOrderIdGenerationById(bean,id);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id删除
	 */
	@RequestMapping("/deleteOrderIdGenerationById")
	public ResponseVO deleteOrderIdGenerationById(Integer id) {
		orderIdGenerationService.deleteOrderIdGenerationById(id);
		return getSuccessResponseVO(null);
	}
}